function init(obj) local new_binder = car_binder(obj) obj:bind_object(new_binder) end --------------------------------------------------------------------------------------------- class "car_binder" (object_binder) function car_binder:__init(obj) super(obj) self.initialized = false self.loaded = false end function car_binder:reload(section) object_binder.reload(self, section) end function car_binder:reinit() object_binder.reinit(self) db.storage[self.object:id()] = db.storage[self.object:id()] and empty_table(db.storage[self.object:id()]) or {} self.st = db.storage[self.object:id()] end function car_binder:update(delta) object_binder.update(self, delta) if not self.initialized and db.actor then self.initialized = true xr_logic.initialize_obj(self.object, self.st, self.loaded, db.actor, modules.stype_item) end if self.st.active_section ~= nil then xr_logic.issue_event(self.object, self.st[self.st.active_scheme], "update", delta) end xr_sound.update(self.object:id()) end function car_binder:net_spawn(se_abstract) if not object_binder.net_spawn(self, se_abstract) then return false end db.add_obj(self.object) self.object:set_callback(callback.hit, car_binder.hit_callback, self) self.object:set_callback(callback.death, car_binder.death_callback, self) self.object:set_callback(callback.use_object, car_binder.use_callback, self) return true end function car_binder:net_destroy() xr_sound.stop_sounds_by_id(self.object:id()) local st = db.storage[self.object:id()] if st.active_scheme then xr_logic.issue_event(self.object, st[st.active_scheme], "net_destroy") end local on_offline_condlist = st and st.overrides and st.overrides.on_offline_condlist if on_offline_condlist ~= nil then xr_logic.pick_section_from_condlist(db.actor, self.object, on_offline_condlist) end if self.particle ~= nil then self.particle:stop() end db.del_obj(self.object) db.storage[self.object:id()] = nil self.object:set_callback(callback.hit, nil) self.object:set_callback(callback.death, nil) self.object:set_callback(callback.use_object, nil) object_binder.net_destroy(self) end function car_binder:net_save_relevant() return true end function car_binder:save(packet) object_binder.save(self, packet) set_save_marker(packet, "save", false, "physics_binder") xr_logic.save_obj(self.object, packet) set_save_marker(packet, "save", true, "physics_binder") end function car_binder:load(reader) self.loaded = true object_binder.load(self, reader) set_save_marker(reader, "load", false, "physics_binder") xr_logic.load_obj(self.object, reader) set_save_marker(reader, "load", true, "physics_binder") end function car_binder:use_callback(obj, who) if self.st.active_section then xr_logic.issue_event(self.object, self.st[self.st.active_scheme], "use_callback", obj, who) end end function car_binder:hit_callback(obj, amount, local_direction, who, bone_index) if self.st.ph_on_hit then xr_logic.issue_event(self.object, self.st.ph_on_hit, "hit_callback", obj, amount, local_direction, who, bone_index) end if self.st.active_section then xr_logic.issue_event(self.object, self.st[self.st.active_scheme], "hit_callback", obj, amount, local_direction, who, bone_index) end end function car_binder:death_callback(victim, who) if self.st.active_section then xr_logic.issue_event(self.object, self.st[self.st.active_scheme], "death_callback", victim, who) end if self.particle ~= nil then self.particle:stop() end end